

<!-- 修改content块宽高为屏幕尺寸 -->

<template>
	<view class="content">
		<!-- 温度模块 需求编号55、58-->
		<view :class="Part1" :hover-class="hoverPart1" @click="Temp">
			<view :class="partA1">
				<view :class="partA_text1">
					<text>{{textT}}</text>
				</view>
				<view class="partA_data">
					<text>{{tempAtext}}</text>
				</view>
			</view>
			<view class="partBCD">
				<view class="partB">
					<view class="partB_text">
						<text>变化趋势</text>
					</view>
					<view class="partB_data">
						<view>
							<image :src="tempChange" style="width: 32rpx;height:17px;"></image>
						<text>{{tempBtext}}</text>
						</view>
					</view>
				</view>
				<view class="partCD">
					<view class="partC">
						<view class="partB_text2">
							<text>风扇</text>
						</view>
						<view class="partB_data2">
							<text>{{tempCtext1}}</text>
						</view>
					</view>
					<view class="partD">
						<view class="partB_text2">
							<text>电灯</text>
						</view>
						<view class="partB_data2">
							<text>{{tempCtext2}}</text>
						</view>
					</view>
				</view>
			</view>
		</view>

		<!-- 空气湿度模块 需求编号56、58-->
		<view :class="Part2" :hover-class="hoverPart2" @click="Air">
			<view :class="partA2">
				<view :class="partA_text2">
					<text>{{textA}}</text>
				</view>
				<view class="partA_data">
					<text>{{AirAtext}}</text>
				</view>
			</view>
			<view class="partBCD">
				<view class="partB">
					<view class="partB_text">
						<text>变化趋势</text>
					</view>
					<view class="partB_data">
						<view>
							<image :src="airChange" style="width: 32rpx;height:17px;"></image>
						<text>{{AirBtext}}</text>
						</view>
					</view>
				</view>
				<view class="partE">
					<view class="partB_text">
						<text>水泵</text>
					</view>
					<view class="partB_data">
						<text>{{pump}}</text>
					</view>
				</view>
			</view>
		</view>

		<!-- 土壤湿度模块 需求编号57、58-->
		<view :class="Part3" :hover-class="hoverPart3" @click="Dust">
			<view :class="partA3">
				<view :class="partA_text3">
					<text>{{textD}}</text>
				</view>
				<view class="partA_data">
					<text>{{DustAtext}}</text>
				</view>
			</view>
			<view class="partBCD">
				<view class="partB">
					<view class="partB_text">
						<text>变化趋势</text>
					</view>
					<view class="partB_data">
						<view>
							<image :src="dustChange" style="width: 32rpx;height:17px;"></image>
							<text>{{DustBtext}}</text>
						</view>
					</view>
				</view>
				<view class="partE">
					<view class="partB_text">
						<text>水泵</text>
					</view>
					<view class="partB_data">
						<text>{{tempCtext2}}</text>
					</view>
				</view>
			</view>
		</view>

		<!-- 光照强度模块 58-->
		<view :class="Part4" :hover-class="hoverPart4" @click="Light">
			<view :class="partA4">
				<view :class="partA_text4">
					<text>{{textL}}</text>
				</view>
				<view class="partA_data" style="font-size: 1.3em;">
					<text>{{LightAtext}}</text>
				</view>
			</view>
			<view class="partBCD">
				<view class="partB">
					<view class="partB_text">
						<text>变化趋势</text>
					</view>
					<view class="partB_data">
						<view>
							<image :src="lightChange" style="width: 32rpx;height:17px;"></image>
							<text>{{LightBtext}}</text>
						</view>
					</view>
				</view>
				<view class="partE">
					<view class="partB_text">
						<text>电灯</text>
					</view>
					<view class="partB_data">
						<text>{{pump}}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		color
	} from 'echarts';
	export default {
		data() {
			return {
				//改变趋势图标地址
				/* ../../static/image/down.png */
				lightChange: '',
				airChange: '',
				dustChange: '',
				tempChange: '',
				//class标签-Air
				Part1: 'Part',
				hoverPart1: 'hoverPart',
				partA1: 'partA',
				partA_text1: 'partA_text',
				//class标签-Air
				Part2: 'Part',
				hoverPart2: 'hoverPart',
				partA2: 'partA',
				partA_text2: 'partA_text',
				//class标签-Air
				Part3: 'Part',
				hoverPart3: 'hoverPart',
				partA3: 'partA',
				partA_text3: 'partA_text',
				//class标签-Air
				Part4: 'Part',
				hoverPart4: 'hoverPart',
				partA4: 'partA',
				partA_text4: 'partA_text',
				//文本
				textT: '温度',
				textA: '空气湿度',
				textD: '土壤湿度',
				textL: '光照强度',
				timer: null, //轮询计时器

				// 温度当前值 变化值 风扇 灯状态
				tempAtext: '无数据',
				tempBtext: '无数据',
				tempCtext1: '无数据',
				tempCtext2: '无数据',

				//空气湿度当前值 变化值 水状态
				AirAtext: '无数据',
				AirBtext: '无数据',
				pump: '无数据',

				//土壤湿度当前值 变化值 水状态
				DustAtext: '无数据',
				DustBtext: '无数据',

				//光照强度当前值 变化值
				LightAtext: '无数据',
				LightBtext: '无数据',
			}
		},
		onLoad() {
			let that = this;
			
			//保证立刻显现数据
			uni.request({
				url: 'http://192.168.5.3:9091/api/getTempHudRealTime', //正式地址
				// url: 'http://127.0.0.1:4523/m1/2888201-0-default/api/getTempHudRealTime', //测试地址
				method: 'GET',
				success(res) {
					//收温度
					console.log(res.data);
					if (res.data.temp != null) {
						that.tempAtext = res.data.temp[res.data.temp.length - 1] + "℃";
						that.tempBtext = res.data.temp[res.data.temp.length - 1] - res.data.temp[res
							.data
							.temp.length - 2] + "℃";
						//补充升降判断
						if(that.tempBtext > 0){
							that.tempChange = '../../static'
						}
						//异常数据检测
						switch (res.data.tempCondition) {
							case 1:
								//正常
								that.Part1 = 'Part';
								that.hoverPart1 = 'hoverPart';
								that.partA1 = 'partA';
								that.partA_text1 = 'partA_text';
								break;
							case 0:
								//过低
								that.Part1 = 'PartDown';
								that.hoverPart1 = 'hoverPartDown';
								that.partA1 = 'partAdown';
								that.partA_text1 = 'partA_textDown';
								uni.showToast({
									title:"温度过低",
									icon:"error",
								});
								break;
							case 2:
								//过高
								that.Part1 = 'PartUp';
								that.hoverPart1 = 'hoverPartUp';
								that.partA1 = 'partAup';
								that.partA_text1 = 'partA_textUp';
								uni.showToast({
									title:"温度过高",
									icon:"error",
								});
								break;
							default:
								that.Part1 = 'PartError';
								that.hoverPart1 = 'hoverPartError';
								that.partA1 = 'partAerror';
								that.partA_text1 = 'partA_textError';
								uni.showToast({
									title:"温度数据异常",
									icon:"error",
								});
						}
					}
			
					//空气湿度
					if (res.data.hum != null) {
						that.AirAtext = res.data.hum[res.data.hum.length - 1] + "%";
						that.AirBtext = res.data.hum[res.data.hum.length - 1] -
							res.data.hum[res.data.hum.length - 2] + "%";
						//补充升降判断
			
						//异常数据检测
						switch (res.data.humCondition) {
							case 1:
								//正常
								that.Part2 = 'Part';
								that.hoverPart2 = 'hoverPart';
								that.partA2 = 'partA';
								that.partA_text2 = 'partA_text';
								break;
							case 0:
								//过低
								that.Part2 = 'PartDown';
								that.hoverPart2 = 'hoverPartDown';
								that.partA2 = 'partAdown';
								that.partA_text2 = 'partA_textDown';
								uni.showToast({
									title:"空气湿度过低",
									icon:"error",
								});
								break;
							case 2:
								//过高
								that.Part2 = 'PartUp';
								that.hoverPart2 = 'hoverPartUp';
								that.partA2 = 'partAup';
								that.partA_text2 = 'partA_textUp';
								uni.showToast({
									title:"空气湿度过高",
									icon:"error",
								});
								break;
							default:
								that.Part2 = 'PartError';
								that.hoverPart2 = 'hoverPartError';
								that.partA2 = 'partAerror';
								that.partA_text2 = 'partA_textError';
								uni.showToast({
									title:"空气湿度数据异常",
									icon:"error",
								});
						}
					}
			
					//土壤湿度
					if (res.data.moisture != null) {
						that.DustAtext = res.data.moisture[res.data.moisture.length - 1] + "%";
						that.DustBtext = res.data.moisture[res.data.moisture.length - 1] -
							res.data.moisture[res.data.moisture.length - 2] + "%";
						//补充升降判断
			
						//异常数据检测
						switch (res.data.moistureCondition) {
							case 1:
								//正常
								that.Part3 = 'Part';
								that.hoverPart3 = 'hoverPart';
								that.partA3 = 'partA';
								that.partA_text3 = 'partA_text';
								break;
							case 0:
								//过低
								that.Part3 = 'PartDown';
								that.hoverPart3 = 'hoverPartDown';
								that.partA3 = 'partAdown';
								that.partA_text3 = 'partA_textDown';
								uni.showToast({
									title:"土壤湿度过低",
									icon:"error",
								});
								break;
							case 2:
								//过高
								that.Part3 = 'PartUp';
								that.hoverPart3 = 'hoverPartUp';
								that.partA3 = 'partAup';
								that.partA_text3 = 'partA_textUp';
								uni.showToast({
									title:"土壤湿度过高",
									icon:"error",
								});
								break;
							default:
								that.Part3 = 'PartError';
								that.hoverPart3 = 'hoverPartError';
								that.partA3 = 'partAerror';
								that.partA_text3 = 'partA_textError';
								uni.showToast({
									title:"土壤湿度读数异常",
									icon:"error",
								});
						}
					}
			
					//光照强度
					if (res.data.intensity != null) {
						that.LightAtext = res.data.intensity[res.data.intensity.length - 1];
						that.LightBtext = res.data.intensity[res.data.intensity.length - 1] -
							res.data.intensity[res.data.intensity.length - 2];
						//补充升降判断
			
						//异常数据检测
						switch (res.data.intensityCondition) {
							case 1:
								//正常
								that.Part4 = 'Part';
								that.hoverPart4 = 'hoverPart';
								that.partA4 = 'partA';
								that.partA_text4 = 'partA_text';
								break;
							case 0:
								//过低
								that.Part4 = 'PartDown';
								that.hoverPart4 = 'hoverPartDown';
								that.partA4 = 'partAdown';
								that.partA_text4 = 'partA_textDown';
								uni.showToast({
									title:"光照强度过低",
									icon:"error",
								});
								break;
							case 2:
								//过高
								that.Part4 = 'PartUp';
								that.hoverPart4 = 'hoverPartUp';
								that.partA4 = 'partAup';
								that.partA_text4 = 'partA_textUp';
								uni.showToast({
									title:"光照强度过高",
									icon:"error",
								});
								break;
							default:
								that.Part4 = 'PartError';
								that.hoverPart4 = 'hoverPartError';
								that.partA4 = 'partAerror';
								that.partA_text4 = 'partA_textError';
								uni.showToast({
									title:"光照强度读数异常",
									icon:"error",
								});
						}
			
						if (that.LightAtext > 99999) {
							//科学计数法化
							that.LightAtext = that.LightAtext.toExponential(1);
						}
					}
				},
				fail() {
					uni.showToast({
						title: "数据请求失败",
						icon: "error"
					});
				}
			});
			//保证设备状态显示
			uni.request({
				url: 'http://192.168.5.3:9091/api/getDeviceState',
				method: 'GET',
				success(res) {
					console.log(res.data)
					if (res.data.pump > 0)
						that.pump = res.data.Pump + "档";
					else
						that.pump = "关闭";
					if (res.data.Fan > 0)
						that.tempCtext1 = res.data.Fan + "档";
					else
						that.tempCtext1 = "关闭";
					if (res.data.Light == 1) {
						that.tempCtext2 = '开启';
					} else {
						that.tempCtext2 = '关闭';
					}
					console.log(that.tempCtext1);
				},
				fail() {
					uni.showToast({
						title: "设备状态请求失败",
						icon: "error"
					});
				}
			});
		},
		//页面加载后开始轮询数据
		onShow() {
			let that = this;

			//保证立刻显现数据
			uni.request({
				url: 'http://192.168.5.3:9091/api/getTempHudRealTime', //正式地址
				method: 'GET',
				success(res) {
					//收温度
					console.log(res.data);
					if (res.data.temp != null) {
						that.tempAtext = res.data.temp[res.data.temp.length - 1] + "℃";
						that.tempBtext = res.data.temp[res.data.temp.length - 1] - res.data.temp[res
							.data
							.temp.length - 2] + "℃";
						//补充升降判断
						if(that.tempBtext > 0){
							that.tempChange = '../../static'
						}
						//异常数据检测
						switch (res.data.tempCondition) {
							case 1:
								//正常
								that.Part1 = 'Part';
								that.hoverPart1 = 'hoverPart';
								that.partA1 = 'partA';
								that.partA_text1 = 'partA_text';
								break;
							case 0:
								//过低
								that.Part1 = 'PartDown';
								that.hoverPart1 = 'hoverPartDown';
								that.partA1 = 'partAdown';
								that.partA_text1 = 'partA_textDown';
								uni.showToast({
									title:"温度过低",
									icon:"error",
								});
								break;
							case 2:
								//过高
								that.Part1 = 'PartUp';
								that.hoverPart1 = 'hoverPartUp';
								that.partA1 = 'partAup';
								that.partA_text1 = 'partA_textUp';
								uni.showToast({
									title:"温度过高",
									icon:"error",
								});
								break;
							default:
								that.Part1 = 'PartError';
								that.hoverPart1 = 'hoverPartError';
								that.partA1 = 'partAerror';
								that.partA_text1 = 'partA_textError';
								uni.showToast({
									title:"温度数据异常",
									icon:"error",
								});
						}
					}

					//空气湿度
					if (res.data.hum != null) {
						that.AirAtext = res.data.hum[res.data.hum.length - 1] + "%";
						that.AirBtext = res.data.hum[res.data.hum.length - 1] -
							res.data.hum[res.data.hum.length - 2] + "%";
						//补充升降判断

						//异常数据检测
						switch (res.data.humCondition) {
							case 1:
								//正常
								that.Part2 = 'Part';
								that.hoverPart2 = 'hoverPart';
								that.partA2 = 'partA';
								that.partA_text2 = 'partA_text';
								break;
							case 0:
								//过低
								that.Part2 = 'PartDown';
								that.hoverPart2 = 'hoverPartDown';
								that.partA2 = 'partAdown';
								that.partA_text2 = 'partA_textDown';
								uni.showToast({
									title:"空气湿度过低",
									icon:"error",
								});
								break;
							case 2:
								//过高
								that.Part2 = 'PartUp';
								that.hoverPart2 = 'hoverPartUp';
								that.partA2 = 'partAup';
								that.partA_text2 = 'partA_textUp';
								uni.showToast({
									title:"空气湿度过高",
									icon:"error",
								});
								break;
							default:
								that.Part2 = 'PartError';
								that.hoverPart2 = 'hoverPartError';
								that.partA2 = 'partAerror';
								that.partA_text2 = 'partA_textError';
								uni.showToast({
									title:"空气湿度数据异常",
									icon:"error",
								});
						}
					}

					//土壤湿度
					if (res.data.moisture != null) {
						that.DustAtext = res.data.moisture[res.data.moisture.length - 1] + "%";
						that.DustBtext = res.data.moisture[res.data.moisture.length - 1] -
							res.data.moisture[res.data.moisture.length - 2] + "%";
						//补充升降判断

						//异常数据检测
						switch (res.data.moistureCondition) {
							case 1:
								//正常
								that.Part3 = 'Part';
								that.hoverPart3 = 'hoverPart';
								that.partA3 = 'partA';
								that.partA_text3 = 'partA_text';
								break;
							case 0:
								//过低
								that.Part3 = 'PartDown';
								that.hoverPart3 = 'hoverPartDown';
								that.partA3 = 'partAdown';
								that.partA_text3 = 'partA_textDown';
								uni.showToast({
									title:"土壤湿度过低",
									icon:"error",
								});
								break;
							case 2:
								//过高
								that.Part3 = 'PartUp';
								that.hoverPart3 = 'hoverPartUp';
								that.partA3 = 'partAup';
								that.partA_text3 = 'partA_textUp';
								uni.showToast({
									title:"土壤湿度过高",
									icon:"error",
								});
								break;
							default:
								that.Part3 = 'PartError';
								that.hoverPart3 = 'hoverPartError';
								that.partA3 = 'partAerror';
								that.partA_text3 = 'partA_textError';
								uni.showToast({
									title:"土壤湿度读数异常",
									icon:"error",
								});
						}
					}

					//光照强度
					if (res.data.intensity != null) {
						that.LightAtext = res.data.intensity[res.data.intensity.length - 1];
						that.LightBtext = res.data.intensity[res.data.intensity.length - 1] -
							res.data.intensity[res.data.intensity.length - 2];
						//补充升降判断

						//异常数据检测
						switch (res.data.intensityCondition) {
							case 1:
								//正常
								that.Part4 = 'Part';
								that.hoverPart4 = 'hoverPart';
								that.partA4 = 'partA';
								that.partA_text4 = 'partA_text';
								break;
							case 0:
								//过低
								that.Part4 = 'PartDown';
								that.hoverPart4 = 'hoverPartDown';
								that.partA4 = 'partAdown';
								that.partA_text4 = 'partA_textDown';
								uni.showToast({
									title:"光照强度过低",
									icon:"error",
								});
								break;
							case 2:
								//过高
								that.Part4 = 'PartUp';
								that.hoverPart4 = 'hoverPartUp';
								that.partA4 = 'partAup';
								that.partA_text4 = 'partA_textUp';
								uni.showToast({
									title:"光照强度过高",
									icon:"error",
								});
								break;
							default:
								that.Part4 = 'PartError';
								that.hoverPart4 = 'hoverPartError';
								that.partA4 = 'partAerror';
								that.partA_text4 = 'partA_textError';
								uni.showToast({
									title:"光照强度读数异常",
									icon:"error",
								});
						}

						if (that.LightAtext > 99999) {
							//科学计数法化
							that.LightAtext = that.LightAtext.toExponential(1);
						}
					}
				},
				fail() {
					uni.showToast({
						title: "数据请求失败",
						icon: "error"
					});
				}
			});
			//保证设备状态显示
			uni.request({
				url: 'http://192.168.5.3:9091/api/getDeviceState',
				method: 'GET',
				success(res) {
					console.log(res.data)
					if (res.data.Pump > 0)
						that.pump = res.data.Pump + "档";
					else
						that.pump = "关闭";
					if (res.data.Fan > 0)
						that.tempCtext1 = res.data.Fan + "档";
					else
						that.tempCtext1 = "关闭";
					if (res.data.Light > 0) {
						that.tempCtext2 = '开启';
					} else {
						that.tempCtext2 = '关闭';
					}
					console.log(that.tempCtext1);
				},
				fail() {
					uni.showToast({
						title: "设备状态请求失败",
						icon: "error"
					});
				}
			});

			//间隔10秒轮询数据
			that.timer = setInterval(() => {
				uni.request({
					url: 'http://192.168.5.3:9091/api/getTempHudRealTime', //正式地址
					// url: 'http://127.0.0.1:4523/m1/2888201-0-default/api/getTempHudRealTime', //测试地址
					method: 'GET',
					success(res) {
						//收温度
						console.log(res.data);
						if (res.data.temp != null) {
							that.tempAtext = res.data.temp[res.data.temp.length - 1] + "℃";
							that.tempBtext = res.data.temp[res.data.temp.length - 1] - res.data.temp[res
								.data
								.temp.length - 2] + "℃";
							//补充升降判断
						
							//异常数据检测
							switch (res.data.tempCondition) {
								case 1:
									//正常
									that.Part1 = 'Part';
									that.hoverPart1 = 'hoverPart';
									that.partA1 = 'partA';
									that.partA_text1 = 'partA_text';
									break;
								case 0:
									//过低
									that.Part1 = 'PartDown';
									that.hoverPart1 = 'hoverPartDown';
									that.partA1 = 'partAdown';
									that.partA_text1 = 'partA_textDown';
									uni.showToast({
										title:"温度过低",
										icon:"error",
									});
									break;
								case 2:
									//过高
									that.Part1 = 'PartUp';
									that.hoverPart1 = 'hoverPartUp';
									that.partA1 = 'partAup';
									that.partA_text1 = 'partA_textUp';
									uni.showToast({
										title:"温度过高",
										icon:"error",
									});
									break;
								default:
									that.Part1 = 'PartError';
									that.hoverPart1 = 'hoverPartError';
									that.partA1 = 'partAerror';
									that.partA_text1 = 'partA_textError';
									uni.showToast({
										title:"温度数据异常",
										icon:"error",
									});
							}
						}
						
						//空气湿度
						if (res.data.hum != null) {
							that.AirAtext = res.data.hum[res.data.hum.length - 1] + "%";
							that.AirBtext = res.data.hum[res.data.hum.length - 1] -
								res.data.hum[res.data.hum.length - 2] + "%";
							//补充升降判断
						
							//异常数据检测
							switch (res.data.humCondition) {
								case 1:
									//正常
									that.Part2 = 'Part';
									that.hoverPart2 = 'hoverPart';
									that.partA2 = 'partA';
									that.partA_text2 = 'partA_text';
									break;
								case 0:
									//过低
									that.Part2 = 'PartDown';
									that.hoverPart2 = 'hoverPartDown';
									that.partA2 = 'partAdown';
									that.partA_text2 = 'partA_textDown';
									uni.showToast({
										title:"空气湿度过低",
										icon:"error",
									});
									break;
								case 2:
									//过高
									that.Part2 = 'PartUp';
									that.hoverPart2 = 'hoverPartUp';
									that.partA2 = 'partAup';
									that.partA_text2 = 'partA_textUp';
									uni.showToast({
										title:"空气湿度过高",
										icon:"error",
									});
									break;
								default:
									that.Part2 = 'PartError';
									that.hoverPart2 = 'hoverPartError';
									that.partA2 = 'partAerror';
									that.partA_text2 = 'partA_textError';
									uni.showToast({
										title:"空气湿度数据异常",
										icon:"error",
									});
							}
						}
						
						//土壤湿度
						if (res.data.moisture != null) {
							that.DustAtext = res.data.moisture[res.data.moisture.length - 1] + "%";
							that.DustBtext = res.data.moisture[res.data.moisture.length - 1] -
								res.data.moisture[res.data.moisture.length - 2] + "%";
							//补充升降判断
						
							//异常数据检测
							switch (res.data.moistureCondition) {
								case 1:
									//正常
									that.Part3 = 'Part';
									that.hoverPart3 = 'hoverPart';
									that.partA3 = 'partA';
									that.partA_text3 = 'partA_text';
									break;
								case 0:
									//过低
									that.Part3 = 'PartDown';
									that.hoverPart3 = 'hoverPartDown';
									that.partA3 = 'partAdown';
									that.partA_text3 = 'partA_textDown';
									uni.showToast({
										title:"土壤湿度过低",
										icon:"error",
									});
									break;
								case 2:
									//过高
									that.Part3 = 'PartUp';
									that.hoverPart3 = 'hoverPartUp';
									that.partA3 = 'partAup';
									that.partA_text3 = 'partA_textUp';
									uni.showToast({
										title:"土壤湿度过高",
										icon:"error",
									});
									break;
								default:
									that.Part3 = 'PartError';
									that.hoverPart3 = 'hoverPartError';
									that.partA3 = 'partAerror';
									that.partA_text3 = 'partA_textError';
									uni.showToast({
										title:"土壤湿度读数异常",
										icon:"error",
									});
							}
						}
						
						//光照强度
						if (res.data.intensity != null) {
							that.LightAtext = res.data.intensity[res.data.intensity.length - 1];
							that.LightBtext = res.data.intensity[res.data.intensity.length - 1] -
								res.data.intensity[res.data.intensity.length - 2];
							//补充升降判断
						
							//异常数据检测
							switch (res.data.intensityCondition) {
								case 1:
									//正常
									that.Part4 = 'Part';
									that.hoverPart4 = 'hoverPart';
									that.partA4 = 'partA';
									that.partA_text4 = 'partA_text';
									break;
								case 0:
									//过低
									that.Part4 = 'PartDown';
									that.hoverPart4 = 'hoverPartDown';
									that.partA4 = 'partAdown';
									that.partA_text4 = 'partA_textDown';
									uni.showToast({
										title:"光照强度过低",
										icon:"error",
									});
									break;
								case 2:
									//过高
									that.Part4 = 'PartUp';
									that.hoverPart4 = 'hoverPartUp';
									that.partA4 = 'partAup';
									that.partA_text4 = 'partA_textUp';
									uni.showToast({
										title:"光照强度过高",
										icon:"error",
									});
									break;
								default:
									that.Part4 = 'PartError';
									that.hoverPart4 = 'hoverPartError';
									that.partA4 = 'partAerror';
									that.partA_text4 = 'partA_textError';
									uni.showToast({
										title:"光照强度读数异常",
										icon:"error",
									});
							}
						
							if (that.LightAtext > 99999) {
								//科学计数法化
								that.LightAtext = that.LightAtext.toExponential(1);
							}
						}
					},
					fail() {
						uni.showToast({
							title: "数据请求失败",
							icon: "error"
						});
					}
				});
				uni.request({
					url: 'http://192.168.5.3:9091/api/getDeviceState',
					method: 'GET',
					success(res) {
						console.log(res.data)
						if (res.data.Pump > 0)
							that.pump = res.data.Pump + "档";
						else
							that.pump = "关闭";
						if (res.data.Fan > 0)
							that.tempCtext1 = res.data.Fan + "档";
						else
							that.tempCtext1 = "关闭";
						if (res.data.Light == 1) {
							that.tempCtext2 = '开启';
						} else {
							that.tempCtext2 = '关闭';
						}
						console.log(that.tempCtext1);
					},
					fail() {
						uni.showToast({
							title: "设备状态请求失败",
							icon: "error"
						});
					}
				});
			}, 10000);
		},

		//清除计时器一般页面onUnload(),tabbar用onHide()
		onHide() {
			if (this.timer) {
				clearTimeout(this.timer);
				this.timer = null;
			}
			console.clear();
		},
		methods: {
			//点击跳转至温度详情页
			Temp() {
				console.log("Tap1");
				uni.navigateTo({
					url: '/pages/message/temp_data/temp_data'
				})
			},
			//点击跳转至大棚湿度详情页
			Air() {
				console.log("Tap3");
				uni.navigateTo({
					url: '/pages/message/Air_data/Air_data'
				});
			},
			//点击跳转至土壤湿度详情页
			Dust() {
				console.log("Tap2");
				uni.navigateTo({
					url: '/pages/message/Dust_data/Dust_data'
				});
			},
			//点击跳转至光照强度详情页
			Light() {
				console.log("Tap4");
				uni.navigateTo({
					url: '/pages/message/Light_data/Light_data'
				});
			},
		}
	}
</script>

<style>
	.content {
		align-items: center;
		justify-content: center;
		width: 100vw;
		height: 85vh;
	}

	/* 正常 过高 过低 错误时的样式 */
	.Part {
		margin: 20rpx auto;
		height: 130px;
		width: 95%;
		border-radius: 20rpx;
		background-color: #d1f2d7;
		box-shadow: 0rpx 0rpx 10rpx rgba(0, 0, 0, 0.55);
	}

	.PartUp {
		margin: 20rpx auto;
		height: 130px;
		width: 95%;
		border-radius: 20rpx;
		background-color: #fdedd9;
		box-shadow: 0rpx 0rpx 10rpx rgba(0, 0, 0, 0.55);
	}

	.PartDown {
		margin: 20rpx auto;
		height: 130px;
		width: 95%;
		border-radius: 20rpx;

		background-color: #d4e4ff;
		box-shadow: 0rpx 0rpx 10rpx rgba(0, 0, 0, 0.55);
	}

	.PartError {
		margin: 20rpx auto;
		height: 130px;
		width: 95%;
		border-radius: 20rpx;
		background-color: #e9e9eb;
		box-shadow: 0rpx 0rpx 10rpx rgba(0, 0, 0, 0.55);
	}

	.hoverPart {
		margin: 10rpx auto;
		height: 130px;
		width: 95%;
		background-color: #8cde9b;
	}

	.hoverPartUp {
		margin: 10rpx auto;
		height: 130px;
		width: 95%;
		background-color: #f29e99;
	}

	.hoverPartDown {
		margin: 10rpx auto;
		height: 130px;
		width: 95%;
		background-color: #94bcff;
	}

	.hoverPartError {
		margin: 10rpx auto;
		height: 130px;
		width: 95%;
		background-color: #c7c9ce;
	}

	/*partA  */
	.partA {
		width: 39%;
		margin-left: 0px;
		height: 100%;
		float: left;
		box-shadow: 10rpx 0rpx 5rpx rgba(0, 0, 0, 0.15);
		border-radius: 10rpx;
		background-color: #18bc37;
	}

	.partAup {
		width: 39%;
		margin-left: 0px;
		height: 100%;
		float: left;
		box-shadow: 10rpx 0rpx 5rpx rgba(0, 0, 0, 0.15);
		border-radius: 10rpx;
		background-color: #e43d33;
	}

	.partAdown {
		width: 39%;
		margin-left: 0px;
		height: 100%;
		float: left;
		box-shadow: 10rpx 0rpx 5rpx rgba(0, 0, 0, 0.15);
		border-radius: 10rpx;
		background-color: #2979ff;
	}

	.partAerror {
		width: 39%;
		margin-left: 0px;
		height: 100%;
		float: left;
		box-shadow: 10rpx 0rpx 5rpx rgba(0, 0, 0, 0.15);
		border-radius: 10rpx;
		background-color: #8f939c;
	}

	.partA_text {
		height: 40%;
		width: 100%;
		float: inherit;
		border-radius: 10rpx;
		font-size: 1.3em;
		text-align: center;
		flex: auto;
		display: flex;
		flex-direction: column;
		justify-content: center;
		box-shadow: 0 10rpx 5rpx rgba(0, 0, 0, 0.15);
		color: #FFFFFF;
		background-color: #8cde9b;
	}

	.partA_textUp {
		height: 40%;
		width: 100%;
		float: inherit;
		border-radius: 10rpx;
		font-size: 1.6em;
		text-align: center;
		flex: auto;
		display: flex;
		flex-direction: column;
		justify-content: center;
		box-shadow: 0 10rpx 5rpx rgba(0, 0, 0, 0.15);
		color: #FFFFFF;
		background-color: #f29e99;
	}

	.partA_textDown {
		height: 40%;
		width: 100%;
		float: inherit;
		border-radius: 10rpx;
		font-size: 1.3em;
		text-align: center;
		flex: auto;
		display: flex;
		flex-direction: column;
		justify-content: center;
		box-shadow: 0 10rpx 5rpx rgba(0, 0, 0, 0.15);
		color: #FFFFFF;
		background-color: #94bcff;
	}

	.partA_textError {
		height: 40%;
		width: 100%;
		float: inherit;
		border-radius: 10rpx;
		font-size: 1.6em;
		text-align: center;
		flex: auto;
		display: flex;
		flex-direction: column;
		justify-content: center;
		box-shadow: 0 10rpx 5rpx rgba(0, 0, 0, 0.15);
		color: #FFFFFF;
		background-color: #c7c9ce;
	}

	.partA_data {
		height: 60%;
		width: 100%;
		border-radius: 10px;
		color: #FFFFFF;
		font-size: calc(40rpx);
		display: flex;
		flex-direction: column;
		align-items: center; //垂直居中
		justify-content: center; //水平居中
	}


	.partBCD {
		width: 60%;
		height: 100%;
		margin: 0px;
		float: left;

	}

	.partB {
		width: 100%;
		height: 50%;
		box-shadow: 0rpx 1rpx 1rpx rgba(0, 0, 0, 0.25);


	}

	.partB_text {
		height: 100%;
		width: 45%;
		float: left;
		margin-left: 5%;
		border-radius: 5px;
		color: #000000;
		font-size: calc(25rpx);
		display: flex;
		flex-direction: column;
		align-items: center; //垂直居中
		justify-content: center; //水平居中

	}

	.partB_data {
		height: 100%;
		width: 50%;
		float: left;
		text-align: center;
		font-size: calc(20px);
		margin: 0px;

		color: #000000;
		font-size: calc(25rpx);
		display: flex;
		flex-direction: column;
		align-items: center; //垂直居中
		justify-content: center; //水平居中
	}

	.partB_text2 {
		height: 50%;
		width: 100%;
		float: left;

		color: #000000;
		font-size: calc(30rpx);
		color: red;
		display: flex;
		flex-direction: column;
		align-items: center; //垂直居中
		justify-content: center; //水平居中

	}

	.partB_data2 {
		height: 50%;
		width: 100%;
		float: left;
		text-align: center;
		font-size: calc(20px);
		margin: 0px;
		color: #000000;
		display: flex;
		flex-direction: column;
		align-items: center; //垂直居中
		justify-content: center; //水平居中


	}

	.partCD {
		width: 100%;
		height: 50%;
		margin-left: 2%;
		float: inherit;

	}

	.partC {
		width: 49%;
		height: 100%;
		float: inherit;
		border-radius: 5px;
		box-shadow: 5rpx 0rpx 5rpx rgba(0, 0, 0, 0.35);

		/* border-style: none solid none none;
		border-color: black; */
	}

	.partD {
		width: 49%;
		height: 100%;
		float: inherit;


	}

	.partE {
		width: 100%;
		height: 50%;

	}
</style>